home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / tjgold.zip / INSTALL.003 / DEMBRS4.PAS < prev    next >
Pascal/Delphi Source File  |  1995-05-29  |  3KB  |  112 lines

  1. {--------------------------------------------------------------------------}
  2. {                Product: TechnoJock's Turbo Toolkit GOLD                  }
  3. {                                                                          }
  4. {                     TTT GOLD - DEMO PROGRAM                        }
  5. {                                                                          }
  6. {                Copyright 1986-1995  TechnoJock Software, Inc.            }
  7. {                           All Rights Reserved                            }
  8. {                          Restricted by License                           }
  9. {--------------------------------------------------------------------------}
  10.  
  11. {Description: DEMBRS4.PAS
  12.               Shows how to display a text file in a browse window and
  13.               have certain lines displayed in a secondary color.
  14. }
  15.  
  16. Program DEMBRS4;
  17.  
  18. {$I GOLDFLAG.INC}
  19.  
  20. uses CRT, GoldAttr, GoldMisc, GoldFast,  GoldList, GoldKey, GoldDir,
  21.           GoldWin, GoldLink, GoldStr;
  22.  
  23. var
  24.   Filename:string;
  25.  
  26.    procedure SetScreen;
  27.    {}
  28.    begin
  29.       Clear(BlueOnLightRed,' ');
  30.       ClearLine(1,YellowOnLightBlue);
  31.       WriteCenter(1,0,' Browsing Gold-Style ');
  32.       ClearLine(25,BlackOnYellow);
  33.       WriteCenter(25,0,'Press ESC to finish...');
  34.    end; { SetScreen }
  35.  
  36.    procedure HighlightLine(var DLL:DoubleLL; Str:string; caseSens: boolean);
  37.    {for fun, highlight everyline with contais the substring STR}
  38.    var
  39.       NodePtr: DoubleNodePtr;
  40.       LineCount: string[10];
  41.       Counter: Longint;
  42.       P: byte;
  43.       TempStr: string;
  44.    begin
  45.       GrowMkWin(20,10,60,13,whiteonBlue,4);
  46.       WriteCenter(11,0,'Scanning File');
  47.       LineCount := IntToStr(DLL.TotalNodes);
  48.       NodePtr := DLL.StartNodePtr;
  49.       Counter := 0;
  50.       while NodePtr <> nil do
  51.       begin
  52.          inc(Counter);
  53.          WriteCenter(12,0,'Processing line '+IntToStr(Counter)+' of '+LineCount);
  54.          TempStr := DLLGetNodeStr(NodePtr,0,0);
  55.          if CaseSens then
  56.             P := pos(Str,TempStr)
  57.          else
  58.             P := pos(SetUpper(Str),SetUpper(TempStr));
  59.          if P > 0 then
  60.             DLLSetBit(NodePtr,Colbit,true);
  61.          NodePtr := NodePtr^.NextPtr;
  62.       end;
  63.       RmWin;
  64.    end; {HighlightLine}
  65.  
  66.    procedure DisplayTheFile;
  67.    {}
  68.    var
  69.       Settings: ListCfg;
  70.       DLL: DoubleLL;
  71.       gResult: integer;
  72.    begin
  73.       {First fill the linked list with the file contents}
  74.       InitDLLStr(DLL);
  75.       DLLSetActiveList(DLL);
  76.       gResult := DLLLoadFromFile(Filename);
  77.       if gResult = 0 then
  78.       begin
  79.          HighLightLine(DLL,'procedure',true);
  80.          HighLightLine(DLL,'function',true);
  81.          {set the state of the browse record}
  82.          InitListCfg(Settings);
  83.          ListAssignDLL(Settings,DLL);
  84.          ListSetWin(Settings,1,2,80,24,1);
  85.          ListSetTwoColors(Settings,True);
  86.          CursorOff;
  87.          RunBrowse(Settings,' Browsing '+FileName);
  88.          CursorOn;
  89.       end
  90.       else
  91.          PromptOK(' Error ','Unable to load the file');
  92.       DLLDestroy;
  93.    end; { DisplayTheFile }
  94.  
  95. begin
  96. {$IFOPT D+}
  97.    HeapRecord;
  98. {$ENDIF}
  99.    SetBlinking(false);
  100.    SetScreen;
  101.    MouseShow(true);
  102.    KeySetFast;
  103.    FileName := FileList('*.pas',' Pick a Pascal file ');
  104.    if Filename = '' then
  105.       PromptOK('','You Cancelled!')
  106.    else
  107.       DisplayTheFile;
  108. {$IFOPT D+}
  109.    HeapCheck;
  110. {$ENDIF}
  111. end.
  112.